home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / include / apache / http_main.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-06  |  7.7 KB  |  178 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APACHE_HTTP_MAIN_H
  60. #define APACHE_HTTP_MAIN_H
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. /*
  67.  * Routines in http_main.c which other code --- in particular modules ---
  68.  * may want to call.  Right now, that's limited to timeout handling.
  69.  * There are two functions which modules can call to trigger a timeout
  70.  * (with the per-virtual-server timeout duration); these are hard_timeout
  71.  * and soft_timeout.
  72.  *
  73.  * The difference between the two is what happens when the timeout
  74.  * expires (or earlier than that, if the client connection aborts) ---
  75.  * a soft_timeout just puts the connection to the client in an
  76.  * "aborted" state, which will cause http_protocol.c to stop trying to
  77.  * talk to the client, but otherwise allows the code to continue normally.
  78.  * hard_timeout(), by contrast, logs the request, and then aborts it
  79.  * completely --- longjmp()ing out to the accept() loop in http_main.
  80.  * Any resources tied into the request's resource pool will be cleaned up;
  81.  * everything that isn't will leak.
  82.  *
  83.  * soft_timeout() is recommended as a general rule, because it gives your
  84.  * code a chance to clean up.  However, hard_timeout() may be the most
  85.  * convenient way of dealing with timeouts waiting for some external
  86.  * resource other than the client, if you can live with the restrictions.
  87.  *
  88.  * (When a hard timeout is in scope, critical sections can be guarded
  89.  * with block_alarms() and unblock_alarms() --- these are declared in
  90.  * alloc.c because they are most often used in conjunction with
  91.  * routines to allocate something or other, to make sure that the
  92.  * cleanup does get registered before any alarm is allowed to happen
  93.  * which might require it to be cleaned up; they * are, however,
  94.  * implemented in http_main.c).
  95.  *
  96.  * NOTE!  It's not "fair" for a hard_timeout to be in scope through calls
  97.  * across modules.  Your module code really has no idea what other modules may
  98.  * be present in the server, and they may not take too kindly to having a
  99.  * longjmp() happen -- it could result in corrupted state.  Heck they may not
  100.  * even take to kindly to a soft_timeout()... because it can cause EINTR to
  101.  * happen on pretty much any syscall, and unless all the libraries and modules
  102.  * in use are known to deal well with EINTR it could cause corruption as well.
  103.  * But things are likely to do much better with a soft_timeout in scope than a
  104.  * hard_timeout.
  105.  * 
  106.  * A module MAY NOT use a hard_timeout() across * sub_req_lookup_xxx()
  107.  * functions, or across run_sub_request() functions.  A module SHOULD NOT use a
  108.  * soft_timeout() in either of these cases, but sometimes there's just no
  109.  * choice.
  110.  *
  111.  * kill_timeout() will disarm either variety of timeout.
  112.  *
  113.  * reset_timeout() resets the timeout in progress.
  114.  */
  115.  
  116. API_EXPORT(void) ap_start_shutdown(void);
  117. API_EXPORT(void) ap_start_restart(int);
  118. API_EXPORT(void) ap_hard_timeout(char *, request_rec *);
  119. void ap_keepalive_timeout(char *, request_rec *);
  120. API_EXPORT(void) ap_soft_timeout(char *, request_rec *);
  121. API_EXPORT(void) ap_kill_timeout(request_rec *);
  122. API_EXPORT(void) ap_reset_timeout(request_rec *);
  123.  
  124. API_EXPORT(void) ap_child_terminate(request_rec *r);
  125. API_EXPORT(void) ap_sync_scoreboard_image(void);
  126. int ap_update_child_status(int child_num, int status, request_rec *r);
  127. void ap_time_process_request(int child_num, int status);
  128. unsigned int ap_set_callback_and_alarm(void (*fn) (int), int x);
  129. API_EXPORT(int) ap_check_alarm(void);
  130.  
  131. void setup_signal_names(char *prefix);
  132.  
  133. #ifndef NO_OTHER_CHILD
  134. /*
  135.  * register an other_child -- a child which the main loop keeps track of
  136.  * and knows it is different than the rest of the scoreboard.
  137.  *
  138.  * pid is the pid of the child.
  139.  *
  140.  * maintenance is a function that is invoked with a reason, the data
  141.  * pointer passed here, and when appropriate a status result from waitpid().
  142.  *
  143.  * write_fd is an fd that is probed for writing by select() if it is ever
  144.  * unwritable, then maintenance is invoked with reason OC_REASON_UNWRITABLE.
  145.  * This is useful for log pipe children, to know when they've blocked.  To
  146.  * disable this feature, use -1 for write_fd.
  147.  */
  148. API_EXPORT(void) ap_register_other_child(int pid,
  149.        void (*maintenance) (int reason, void *data, ap_wait_t status), void *data,
  150.                       int write_fd);
  151. #define OC_REASON_DEATH        0    /* child has died, caller must call
  152.                      * unregister still */
  153. #define OC_REASON_UNWRITABLE    1    /* write_fd is unwritable */
  154. #define OC_REASON_RESTART    2    /* a restart is occuring, perform
  155.                      * any necessary cleanup (including
  156.                      * sending a special signal to child)
  157.                      */
  158. #define OC_REASON_UNREGISTER    3    /* unregister has been called, do
  159.                      * whatever is necessary (including
  160.                      * kill the child) */
  161. #define OC_REASON_LOST        4    /* somehow the child exited without
  162.                      * us knowing ... buggy os? */
  163.  
  164. /*
  165.  * unregister an other_child.  Note that the data pointer is used here, and
  166.  * is assumed to be unique per other_child.  This is because the pid and
  167.  * write_fd are possibly killed off separately.
  168.  */
  169. API_EXPORT(void) ap_unregister_other_child(void *data);
  170.  
  171. #endif
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. #endif    /* !APACHE_HTTP_MAIN_H */
  178.